Skip to content

add script output to GitOps#44728

Merged
MagnusHJensen merged 2 commits into
mainfrom
44082-add-script-output-to-gitops
May 7, 2026
Merged

add script output to GitOps#44728
MagnusHJensen merged 2 commits into
mainfrom
44082-add-script-output-to-gitops

Conversation

@MagnusHJensen
Copy link
Copy Markdown
Member

@MagnusHJensen MagnusHJensen commented May 5, 2026

Related issue: Resolves #44082

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

  • Timeouts are implemented and retries are limited to avoid infinite loops

  • If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features

    • Enhanced GitOps script logging: reports how many scripts would be applied in dry‑run mode or were actually applied, with per-team and per-fleet breakdowns.
  • Tests

    • Added test coverage validating logging output for both dry‑run and real execution, ensuring reported script counts and per-team/fleet messages are accurate.

Copilot AI review requested due to automatic review settings May 5, 2026 13:02
@MagnusHJensen MagnusHJensen requested a review from a team as a code owner May 5, 2026 13:02
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6949dcd3-f229-4052-b77f-34bc6474ff0b

📥 Commits

Reviewing files that changed from the base of the PR and between 6567bbc and ab62ecd.

📒 Files selected for processing (2)
  • changes/44082-add-script-output-to-gitops
  • cmd/fleetctl/fleetctl/gitops_test.go
✅ Files skipped from review due to trivial changes (1)
  • changes/44082-add-script-output-to-gitops

Walkthrough

Adds GitOps output for scripts and a changelog entry documenting it. Server client logging in ApplyGroup now reports script counts differently for dry-run (uses payload count) and non-dry-run (uses server-returned count) for both no-team and per-team script applications. Adds TestGitOpsScriptsLogging to assert the presence of per-script log lines in dry-run and real-run scenarios for global and team GitOps YAMLs.

Possibly related PRs

  • fleetdm/fleet#44291: Adds the POST /api/v1/fleet/scripts/batch endpoint and GitOps endpoint tests, touching the same batch script application flow used by the logging changes.
  • fleetdm/fleet#44432: Modifies gitops script handling in server/service/client.go and adds gitops tests, overlapping the ApplyGroup script handling and test paths updated here.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding script output to GitOps functionality.
Description check ✅ Passed The PR description follows the template structure and includes a related issue reference, completed checklist items covering changes files, validation, testing, and manual QA.
Linked Issues check ✅ Passed The PR addresses all requirements from issue #44082: adds script output in both dry-run and real modes via logging in ApplyGroup, includes test coverage in TestGitOpsScriptsLogging, and documents the change in the changes file.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing script output for GitOps: test additions, logging implementation in client.go, and a changes file entry—all aligned with issue #44082 requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 44082-add-script-output-to-gitops

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@changes/44082-add-script-output-to-gitops`:
- Line 1: Replace the ungrammatical phrase "indicating how many would or be
applied when running." with the corrected wording "indicating how many scripts
would be applied (dry run) or were applied." Locate the string in the change
titled 44082-add-script-output-to-gitops (the commit/message or constant
containing that sentence) and update it to the suggested phrasing so the release
note reads clearly.

In `@cmd/fleetctl/fleetctl/gitops_test.go`:
- Around line 6637-6669: The test writes YAML using env substitutions but never
sets FLEET_SERVER_URL, ORG_NAME, or TEST_TEAM_NAME; set these explicitly before
creating globalPath and teamPath (e.g., call os.Setenv("FLEET_SERVER_URL",
"http://localhost:8080"), os.Setenv("ORG_NAME", "test-org"),
os.Setenv("TEST_TEAM_NAME", "test-team")) and add defers to restore/unset them
(defer os.Unsetenv(...)) so the test is deterministic; update the setup near
tmpDir/globalPath and tmpDir/teamPath creation in gitops_test.go to include
these os.Setenv and cleanup calls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ec2cb67c-e77c-41e5-8e70-ea7afcaa801f

📥 Commits

Reviewing files that changed from the base of the PR and between 4039459 and 48ca345.

📒 Files selected for processing (3)
  • changes/44082-add-script-output-to-gitops
  • cmd/fleetctl/fleetctl/gitops_test.go
  • server/service/client.go

Comment thread changes/44082-add-script-output-to-gitops Outdated
Comment thread cmd/fleetctl/fleetctl/gitops_test.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds GitOps CLI output for script changes so users can see when scripts are applied (or would be applied in --dry-run), addressing the gap described in #44082.

Changes:

  • Add logging in ApplyGroup for both no-team and team script batch operations (dry-run and real mode).
  • Add a fleetctl GitOps test asserting the new script-related log lines are present.
  • Add a changelog entry noting the new GitOps script output.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
server/service/client.go Emit GitOps log lines for script application in dry-run and real runs (no-team + per-team).
cmd/fleetctl/fleetctl/gitops_test.go Add regression test verifying script logging appears in both dry-run and real runs.
changes/44082-add-script-output-to-gitops Document the user-visible GitOps output change for scripts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/service/client.go
Comment thread changes/44082-add-script-output-to-gitops Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.71%. Comparing base (26a8345) to head (ab62ecd).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #44728      +/-   ##
==========================================
+ Coverage   66.66%   66.71%   +0.05%     
==========================================
  Files        2672     2674       +2     
  Lines      214802   215468     +666     
  Branches     9945     9945              
==========================================
+ Hits       143206   143760     +554     
- Misses      58564    58641      +77     
- Partials    13032    13067      +35     
Flag Coverage Δ
backend 68.59% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MagnusHJensen
Copy link
Copy Markdown
Member Author

Unrelated test failures

@MagnusHJensen
Copy link
Copy Markdown
Member Author

@JordanMontgomery I had to rebase to fix merge conflicts

@MagnusHJensen MagnusHJensen merged commit 9d96d6c into main May 7, 2026
59 checks passed
@MagnusHJensen MagnusHJensen deleted the 44082-add-script-output-to-gitops branch May 7, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitOps does not output information about script

3 participants